/*
 * @(#)WorkflowQueryRecordParser.java
 *
 * Copyright (c) 2004 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

package com.dcivision.workflow.bean;

import java.io.IOException;
import java.sql.Connection;
import java.util.List;

import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

import com.dcivision.framework.SessionContainer;
import com.dcivision.framework.xml.XMLUtility;

/**
 * WorkflowQueryRecordParser.java
 * 
 * This class is the serializable bean reflecting business logic uses.
 * 
 * @author Jenny Li
 * @company DCIVision Limited
 * @creation date 02/09/2004
 * @version $Revision: 1.7.2.1 $
 * @see com.dcivision.workflow.bean.WorkflowQueryRecord
 */
public class WorkflowQueryRecordParser extends XMLUtility {
  
  public static final String REVISION = "$Revision: 1.7.2.1 $";
  
  
  /** Creates a new instance of ArchiveDataFileTransformer */
  public WorkflowQueryRecordParser() {}
  
  public WorkflowQueryRecordParser(String file) {
    super(file);
  }
  List rootList = null;
  SessionContainer ctx=null;
  Connection conn = null;
  
  private String taskType = null;
  private String priority = null;
  
  
  private String datePeriodFrom = null;
  private String datePeriodTo = null;
  private String status = null;
  private String workflowCategoryID = null;
  private String submitter = null;
  private String workflowRecordID = null;
  private String actionTaker = null;
  private String trackID = null;
  private String stepName = null;
  private String relatedObject = null;
  private String workflowDescription = null;
  private String periodType = null;
  private String periodTimes = null;
  private String periodTimeType = null;
  private String taskComment=null;
  private String attachmentName=null;
  private String stageName = null;
  private String workflowGroupID = null;
  
  /**
   * @param taskComment The taskComment to set.
   */
  public void setTaskComment (String taskComment) {
    this.taskComment = taskComment;
  }
  /**
   * @return Returns the taskComment.
   */
  public String getTaskComment() {
    return (this.taskComment);
  }
  /**
   * @param attachmentName The attachmentName to set.
   */
  public void setAttachmentName (String attachmentName) {
    this.attachmentName = attachmentName;
  }
  /**
   * @return Returns the attachmentName.
   */
  public String getAttachmentName () {
    return (this.attachmentName);
  }
  /**
   * @param rootList The rootList to set.
   */
  public void setRootList (List rootList) {
    this.rootList = rootList;
  }
  /**
   * @return Returns the rootList.
   */
  public List getRootList () {
    return (this.rootList);
  }
  /**
   * @param ctx The ctx to set.
   */
  public void setSessionContainer (SessionContainer ctx) {
    this.ctx = ctx;
  }
  /**
   * @return Returns the ctx.
   */
  public SessionContainer getSessionContainer () {
    return (this.ctx);
  }
  /**
   * @param conn The conn to set.
   */
  public void setConnection (Connection conn) {
    this.conn = conn;
  }
  /**
   * @return Returns the conn.
   */
  public Connection getConnection () {
    return (this.conn);
  }
  
  /**
   * @return Returns the priority.
   */
  public String getPriority() {
    return (this.priority);
  }
  /**
   * @param priority The priority to set.
   */
  public void setPriority(String priority) {
    this.priority = priority;
  }
  /**
   * @return Returns the periodTimes.
   */
  public String getPeriodTimes() {
    return periodTimes;
  }
  /**
   * @param periodTimes The periodTimes to set.
   */
  public void setPeriodTimes(String periodTimes) {
    this.periodTimes = periodTimes;
  }
  /**
   * @return Returns the periodTimeType.
   */
  public String getPeriodTimeType() {
    return periodTimeType;
  }
  /**
   * @param periodTimeType The periodTimeType to set.
   */
  public void setPeriodTimeType(String periodTimeType) {
    this.periodTimeType = periodTimeType;
  }
  /**
   * @return Returns the periodType.
   */
  public String getPeriodType() {
    return periodType;
  }
  /**
   * @param periodType The periodType to set.
   */
  public void setPeriodType(String periodType) {
    this.periodType = periodType;
  }
  
  /**
   * @return Returns the actionTaker.
   */
  public String getActionTaker() {
    return actionTaker;
  }
  /**
   * @param actionTaker The actionTaker to set.
   */
  public void setActionTaker(String actionTaker) {
    this.actionTaker = actionTaker;
  }
  
  /**
   * @return Returns the ctx.
   */
  public SessionContainer getCtx() {
    return ctx;
  }
  /**
   * @param ctx The ctx to set.
   */
  public void setCtx(SessionContainer ctx) {
    this.ctx = ctx;
  }
  /**
   * @return Returns the datePeriodFrom.
   */
  public String getDatePeriodFrom() {
    return datePeriodFrom;
  }
  /**
   * @param datePeriodFrom The datePeriodFrom to set.
   */
  public void setDatePeriodFrom(String datePeriodFrom) {
    this.datePeriodFrom = datePeriodFrom;
  }
  /**
   * @return Returns the datePeriodTo.
   */
  public String getDatePeriodTo() {
    return datePeriodTo;
  }
  /**
   * @param datePeriodTo The datePeriodTo to set.
   */
  public void setDatePeriodTo(String datePeriodTo) {
    this.datePeriodTo = datePeriodTo;
  }
  /**
   * @return Returns the relatedObject.
   */
  public String getRelatedObject() {
    return relatedObject;
  }
  /**
   * @param relatedObject The relatedObject to set.
   */
  public void setRelatedObject(String relatedObject) {
    this.relatedObject = relatedObject;
  }
  /**
   * @return Returns the status.
   */
  public String getStatus() {
    return status;
  }
  /**
   * @param status The status to set.
   */
  public void setStatus(String status) {
    this.status = status;
  }
  /**
   * @return Returns the stepName.
   */
  public String getStepName() {
    return stepName;
  }
  /**
   * @param stepName The stepName to set.
   */
  public void setStepName(String stepName) {
    this.stepName = stepName;
  }
  /**
   * @return Returns the submitter.
   */
  public String getSubmitter() {
    return submitter;
  }
  /**
   * @param submitter The submitter to set.
   */
  public void setSubmitter(String submitter) {
    this.submitter = submitter;
  }
  /**
   * @return Returns the taskType.
   */
  public String getTaskType() {
    return taskType;
  }
  /**
   * @param taskType The taskType to set.
   */
  public void setTaskType(String taskType) {
    this.taskType = taskType;
  }
  /**
   * @return Returns the trackID.
   */
  public String getTrackID() {
    return trackID;
  }
  /**
   * @param trackID The trackID to set.
   */
  public void setTrackID(String trackID) {
    this.trackID = trackID;
  }
  /**
   * @return Returns the workflowCategoryID.
   */
  public String getWorkflowCategoryID() {
    return workflowCategoryID;
  }
  /**
   * @param workflowCategoryID The workflowCategoryID to set.
   */
  public void setWorkflowCategoryID(String workflowCategoryID) {
    this.workflowCategoryID = workflowCategoryID;
  }
  /**
   * @return Returns the workflowDescription.
   */
  public String getWorkflowDescription() {
    return workflowDescription;
  }
  /**
   * @param workflowDescription The workflowDescription to set.
   */
  public void setWorkflowDescription(String workflowDescription) {
    this.workflowDescription = workflowDescription;
  }
  /**
   * @return Returns the workflowRecordID.
   */
  public String getWorkflowRecordID() {
    return workflowRecordID;
  }
  /**
   * @param workflowRecordID The workflowRecordID to set.
   */
  public void setWorkflowRecordID(String workflowRecordID) {
    this.workflowRecordID = workflowRecordID;
  }
  
	public String getStageName() {
		return stageName;
	}
	
	public void setStageName(String stageName) {
		this.stageName = stageName;
	}
  
	public String getWorkflowGroupID() {
		return workflowGroupID;
	}
  
	public void setWorkflowGroupID(String workflowGroupID) {
		this.workflowGroupID = workflowGroupID;
	}
  
  /**
   * this function is to generate XML
   */
  public void parse(InputSource inputSource) throws IOException, SAXException {
    try{
      ContentHandler handler = this.getContentHandler();
      handler.startDocument();
      
      //write root tag
      AttributesImpl rootElementAtt = new AttributesImpl();
      rootElementAtt.addAttribute("","","xmlns","","http://tempuri.org/data_file.xsd");
      rootElementAtt.addAttribute("","","name", "","query_name");
      this.writeStartTag("search_template", "", rootElementAtt);
      
      //indention
      this.setIndent("\n\t");
      
      this.writeStartTag("query","",new AttributesImpl());
      
      //indention
      this.setIndent("\n\t");
      
      
      
      //write name tag
      this.setIndent("\n\t\t");
      this.writeTag("taskType",this.getTaskType(),new AttributesImpl());
      this.writeTag("actionTaker",this.getActionTaker(),new AttributesImpl());
      this.writeTag("priority",this.getPriority(),new AttributesImpl());
      
      
      this.writeStartTag("Query_date","",new AttributesImpl());
      //    indention
      this.setIndent("\n\t\t\t");
      //write Query_date tag
      this.writeTag("from",this.getDatePeriodFrom(),new AttributesImpl());
      this.writeTag("to",this.getDatePeriodTo(),new AttributesImpl());
      //indention
      this.setIndent("\n\t\t");
      this.writeEndTag("Query_date");
      
      this.writeTag("status",this.getStatus(),new AttributesImpl());
      this.writeTag("workflowCategoryID",this.getWorkflowCategoryID(),new AttributesImpl());
      this.writeTag("submitter",this.getSubmitter(),new AttributesImpl());
      this.writeTag("workflowRecordID",this.getWorkflowRecordID(),new AttributesImpl());
      
      this.writeTag("tractID",this.getTrackID(),new AttributesImpl());
      this.writeTag("stepName",this.getStepName(),new AttributesImpl());
      this.writeTag("relatedObject",this.getRelatedObject(),new AttributesImpl());
      this.writeTag("description",this.getWorkflowDescription(),new AttributesImpl());
      this.writeTag("periodTimes",this.getPeriodTimes(),new AttributesImpl());
      this.writeTag("periodTimeType",this.getPeriodTimeType(),new AttributesImpl());
      this.writeTag("periodType",this.getPeriodType(),new AttributesImpl());
      this.writeTag("stageName",this.getStageName(),new AttributesImpl());
      //added by nancy
      this.writeTag("taskComment",this.getTaskComment(),new AttributesImpl());
      this.writeTag("attachmentName",this.getAttachmentName(),new AttributesImpl());
      //end
      this.writeTag("workflowGroupID",this.getWorkflowGroupID(),new AttributesImpl());
      this.setIndent("\n\t");
      
      this.writeEndTag("query");
      
      //indention
      this.setIndent("\n");
      
      this.writeEndTag("search_template");
      
      //end the document
      handler.endDocument();
    }catch(Exception e){log.error(e, e);}
  }
  
  
  
}